#ifndef INCLUDED_ENGINE_RESOURCE_H
#define INCLUDED_ENGINE_RESOURCE_H

//====================================================================================================
// Filename:	Resource.h
// Created by:	Josh Blidook
// Description:	Base Class for a resource counting resource
//====================================================================================================

//====================================================================================================
// Includes
//====================================================================================================



class Resource
{
public:
	Resource()
		: mRefCount(0)
	{}

	virtual ~Resource() // The child class might need to destruct certain things
	{}

	void AddRef()
	{
		++mRefCount;
	}
	void Release()
	{
		ASSERT(mRefCount > 0, "[Resource] Cannot release resource with 0 references!");
		if(--mRefCount == 0) // Assert before this kind of thing, this might WRAP AROUND
		{
			delete this;
		}
	}

	u32 GetRefCount()
	{
		return mRefCount;
	}

private:
	u32 mRefCount; // Might want to make this atomic so it is thread safe *******************************
};

#endif // #ifndef INCLUDED_ENGINE_RESOURCE_H